package com.huawei.hianalytics.process;

import com.huawei.hianalytics.e.f;
import com.huawei.hianalytics.g.b;
import com.huawei.hianalytics.util.g;
import com.huawei.hianalytics.util.h;
import java.util.Arrays;

public class HiAnalyticsLogConfig {
    private f logData;

    private HiAnalyticsLogConfig(Builder builder) {
        this.logData = new f();
        setMinLogLevel(Builder.access$000(builder));
        setFileMaxSize(Builder.access$100(builder));
        setFailedFileMaxSize(Builder.access$200(builder));
        setMcc(Builder.access$300(builder));
        setLogServerUrl(Builder.access$400(builder));
        setThrowableInfo(Builder.access$500(builder));
        setThrowableFlag(Builder.access$600(builder));
        setLogIsEnableImei(Builder.access$700(builder));
        setLogIsEnableUdid(Builder.access$800(builder));
        setLogIsEnableSN(Builder.access$900(builder));
        setLogImei(Builder.access$1000(builder));
        setLogUdid(Builder.access$1100(builder));
        setLogSN(Builder.access$1200(builder));
    }

    private void setFailedFileMaxSize(int i) {
        this.logData.c(g.a(i, 10, 5));
    }

    private void setFileMaxSize(int i) {
        this.logData.b(g.a(i, 10, 3));
    }

    private void setLogImei(String str) {
        this.logData.c(str);
    }

    private void setLogIsEnableImei(boolean z) {
        this.logData.a(z);
    }

    private void setLogIsEnableSN(boolean z) {
        this.logData.c(z);
    }

    private void setLogIsEnableUdid(boolean z) {
        this.logData.b(z);
    }

    private void setLogSN(String str) {
        this.logData.e(str);
    }

    private void setLogServerUrl(String str) {
        if (!h.a(str)) {
            b.b("HiAnalytics/logServer", "log server url check failed");
            str = "";
        }
        if (str.endsWith("/") || str.endsWith("\\")) {
            str = str.substring(0, str.length() - 1);
        }
        this.logData.b(str);
    }

    private void setLogUdid(String str) {
        this.logData.d(str);
    }

    private void setMcc(String str) {
        this.logData.a(g.a(str, 999, 100));
    }

    private void setMinLogLevel(int i) {
        if (3 > i || i > 6) {
            b.c("HiAnalytics/logServer", "HiAnalyticsLogConfig.setMinLogLevel(): minLogLevel: " + i + " invalid. Replaced with default value");
            this.logData.a(4);
            return;
        }
        this.logData.a(i);
    }

    private void setThrowableFlag(int i) {
        if (i == 0 || i == 1) {
            this.logData.d(i);
            return;
        }
        b.b("HiAnalytics/logServer", "The throwableFlag is wrong. Set to default value.");
        this.logData.d(0);
    }

    private void setThrowableInfo(String[] strArr) {
        if (strArr == null) {
            this.logData.a(new String[0]);
        } else if (Arrays.toString(strArr).length() > 204800) {
            b.c("HiAnalytics/logServer", "The throwableInfo parameter is too long!");
            this.logData.a(new String[0]);
        } else {
            this.logData.a((String[]) strArr.clone());
        }
    }

    f getLogData() {
        return this.logData;
    }
}
